<?php	ob_start();

  	include_once '../includes/constants.php';
  	include_once '../includes/functions.php';
  	include_once '../includes/session.php';
   	include_once '../includes/allstripslashes.php';
    include	'lang/english.php';

	$partners=new partners;
	$partners->connection($host,$user,$pass,$db);
	include_once 'language_include.php';

	$err=0;

  ?>
    <link rel="stylesheet" type="text/css" href="main.css">
    <SCRIPT LANGUAGE=javascript type="text/javascript">

	function button1_onclick() {
	window.close();
	}

	</SCRIPT>


  <?

if(isset($B1))
{
	if($emailid=="" || $newpassword=="" || $confirmpassword=="")
	{
	               $msg=$lang_account_blank ;
	               $err=1;
	}

	if($partners->is_email($emailid)==0)
	{
	           $msg=$emailerr;
	           $err=1;
	 }

	if($err==0)
	{
            $emailid;
            if($origin==trim($emailid))
                     {
                             if($newpassword==$confirmpassword)
                                {
										$newpassword	= addslashes($newpassword);
                                      $sql="UPDATE `partners_login` SET `login_password` = '$newpassword' where login_id ='$_SESSION[AFFILIATEID]' and login_flag='a'";
                                      mysql_query($sql);

                                      echo "<p>&nbsp;</p><p>&nbsp;</p>
                                                     <table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='96%' id='AutoNumber1' class='tablebdr'>
                                                             <tr>
                                                               <td width='100%' class='tdhead'>
                                                               &nbsp;</td>
                                                             </tr>
                                                             <tr>
                                                               <td width='100%'>
                                                               <p align='center'><font size='5'>$lang_pass_success</font></td>
                                                             </tr>
                                                             <tr>
                                                               <td width='100%'>
                                                               &nbsp;</td>
                                                             </tr>
                                                             <tr>
                                                               <td width='100%'>
                                                               <p align='center'><INPUT id=button1 type=button align=middle value=close name=button1 LANGUAGE=javascript onclick='return button1_onclick()'></td>
                                                             </tr>
                                                             <tr>
                                                               <td width='100%' class='tdhead'>
                                                               <p align='center'>&nbsp;</td>
                                                             </tr>
                                                           </table> ";

                                         exit;
                                 }else{
                                    $msg=$pass_mismatch	;
                                 }
                     }
                     else
                     {

                               if($newpassword==$confirmpassword)
                                {


                                        $sql    = "select * from partners_login where login_email='$emailid'";
                                         $result = mysql_query($sql);
                                         if(mysql_num_rows($result)>0)
                                         {
                                         $msg=    $lang_EmailIdAlreadyExist;
                                         }
                                         else
                                         {

                                         $sql="UPDATE `partners_login` SET `login_email` = '$emailid',
                                         `login_password` = '$newpassword' where login_id ='$_SESSION[AFFILIATEID]' AND login_flag='a'";

                                         mysql_query($sql);

                                               echo "<p>&nbsp;</p><p>&nbsp;</p>
                                                     <table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='96%' id='AutoNumber1' class='tablebdr'>
                                                             <tr>
                                                               <td width='100%' class='tdhead'>
                                                               &nbsp;</td>
                                                             </tr>
                                                             <tr>
                                                               <td width='100%'>
                                                               <p align='center'><font size='5'>$lang_pass_success</font></td>
                                                             </tr>
                                                             <tr>
                                                               <td width='100%'>
                                                               &nbsp;</td>
                                                             </tr>
                                                             <tr>
                                                               <td width='100%'>
                                                               <p align='center'><INPUT id=button1 type=button align=middle value=close name=button1 LANGUAGE=javascript onclick='return button1_onclick()'></td>
                                                             </tr>
                                                             <tr>
                                                               <td width='100%' class='tdhead'>
                                                               <p align='center'>&nbsp;</td>
                                                             </tr>
                                                           </table> ";

                                         exit;

                                         }

                                }
                                else
                                {
                                  $msg=$pass_mismatch;
                                }

                     }

           }

 }

 else
 {
     $msg="";
      $sql    = "select * from partners_login where login_id ='$_SESSION[AFFILIATEID]' and login_flag='a'";
            $result = mysql_query($sql);

             while($row=mysql_fetch_object($result))
                    {
                                 $emailid=$row->login_email;
                                 $origin=$row->login_email;
                                 $oldpassword=$row->login_password;
                     }

    }

?>

<html>
<body>


<title><?=$logine_edit?></title>

<form method="POST" action="" >



<div align="center">
  <center>



<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="72%" id="AutoNumber1" height="129" class="tablebdr">
    <tr>
      <td width="100%" colspan="4" height="19" class="tdhead">
      <p align="center"><?=$lang_LoginInfoEdit?></td>
    </tr>
    <tr>
      <td width="100%" height="22" colspan="4" class="textred">
      <p align="center"><?=$msg?>&nbsp;</td>
    </tr>
    <tr>
      <td width="2%" height="22">&nbsp;</td>
      <td width="48%" height="22"><?=$lang_EmailId?></td>
      <td width="48%" height="22"><input type="text" name="emailid" size="27" value=<?=$emailid?> ></td>
      <td width="2%" height="22">&nbsp;</td>
      <input name="origin" type="hidden" value=<?=$origin?>>
    </tr>
    <tr>
      <td width="2%" height="22">&nbsp;</td>
      <td width="48%" height="22"><?=$lang_OldPassword?></td>
      <td width="48%" height="22">
      <input type="password" name="oldpassword" size="27" value=<?=$oldpassword?> ></td>
      <td width="2%" height="22">&nbsp;</td>
    </tr>
    <tr>
      <td width="2%" height="22">&nbsp;</td>
      <td width="48%" height="22"><?=$lang_NewPassword?></td>
      <td width="48%" height="22">
      <input type="password" name="newpassword" size="27"></td>
      <td width="2%" height="22">&nbsp;</td>
    </tr>
    <tr>
      <td width="2%" height="19">&nbsp;</td>
      <td width="48%" height="19"><?=$lang_ConfirmPassword?></td>
      <td width="48%" height="19">
      <input type="password" name="confirmpassword" size="27"></td>
      <td width="2%" height="19">&nbsp;</td>
    </tr>
    <tr>
      <td width="100%" colspan="4" height="20">&nbsp;
      </td>
    </tr>
    <tr>
      <td width="49%" colspan="2" height="28" class="tdhead">
      <p align="center"><input type="submit" value="<?=$common_edit?>" name="B1" title="<?=$lang_Edit?>"></td>
      <td width="51%" colspan="2" height="28" class="tdhead">
      <p align="center"><INPUT type="button" value="<?=$lang_close?>" name="button1" onclick="return button1_onclick()"></td>
    </tr>
  </table>
  </center>
</div>
</form>

</body>

</html>